package org.chen.model.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ArticleVO {
    private String id;
    private String title;
    private String author;
    private String summary;
    private String contentHtml;
    private List<String> leadParagraphs;
    private String category;
    private List<String> tags;
    private String thumbnailUrl;
    private String mainImageUrl;
    private String source;
    private Integer status;
    private Boolean isTop;
    private Boolean isHot;
    private Boolean isRecommend;
    private Long viewCount;
    private Integer sortOrder;
    private Integer topOrder;
    private Integer hotOrder;
    private Integer recommendOrder;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    // 额外的展示字段
    private String statusText; // 状态文本
    private String sourceText; // 来源文本
    private List<ImageInfoVO> images; // 图片信息

    // 获取状态文本
    public String getStatusText() {
        if (status == null) return "";
        return switch (status) {
            case 0 -> "草稿";
            case 1 -> "已发布";
            case 2 -> "已下架";
            default -> "未知状态";
        };
    }

    // 获取来源文本
    public String getSourceText() {
        if (source == null) return "";
        return "admin".equals(source) ? "管理员" : "爬虫";
    }
}
